fn steady(n: u32) -> bool {
    fn iter(n: u32, m: u32) -> u64 {
        if m <= n {iter(n, 10 * m)}
        else {m as u64}
    }
    let nl = n as u64;
    nl * nl % iter(n, 1) == nl
}

fn main() {
    let limit = 10_000_000;
    let list5 = (5..=limit).step_by(10)
                .flat_map(|n|[n, n+1])
                .filter(|&n| steady(n));
    let list: Vec<u32> = (0..2).into_iter().chain(list5).collect();

    for n in list {
        let nl = n as u64;
        println!("{}^2 = {}", n, nl*nl);
    }
 }
